Expand description

html_editor is a simple html parser and editor.

Quick Start:

use html_editor::operation::*;
use html_editor::{parse, Node};

// You can create DOM nodes by parsing html string.
let html = r#"
    <!doctype html>
    <html>
        <head>
        </head>
        <body>
        </body>
    </html>
"#;
let mut dom = parse(html).unwrap();

// Or you can create a node by some built-in methods like below.
let app: Node = Node::new_element("div", vec![("id", "app")], vec![]);

// Here shows how to edit the nodes and turn it back to html.
let html = dom
    .remove_by(&Selector::from("head"))
    .insert_to(&Selector::from("body"), app)
    .trim()
    .html();

assert_eq!(
    html,
    r#"<!DOCTYPE html><html><body><div id="app"></div></body></html>"#
);

Modules

All traits for editing, querying and stringifying the Element / Node.

Structs

HTML Element

Enums

Doctype of Html or Xml

Node of DOM

Functions

Parse the html string and return a Vector of Node.

Alternative for parse() with fault tolerance feature.